import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== data
const data =[
	{ name:'+' , value:'0' },
	{ name:'++' , value:'1' },
	{ name:'+++' , value:'2' },
	{ name:'++++' , value:'3' },
	{ name:'+/-' , value:'4' }
]
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		formData : [
			{ label: '溶血',		name: 'rongxue', type: 'radio', data, full:true },
			{ label: '脂血',		name: 'zhixue',	 type: 'radio', data, full:true },
			{ label: '黄疸',		name: 'handan',	 type: 'radio', data, full:true },
			{ label: '其他',		name: 'other', full:true },
		]
	}
	
	open = async (submit, getInfo, rowsType) => {
		
		this.modal.open({ formRef:this.formRef })
		
		this.initSubmit = { spec_abnormal: {rongxue: '', zhixue: '', handan: '', other: ''}, ...submit }
		// 回显
		try{
			const { spec_abnormal } = await getInfo()
			const value = JSON.parse(spec_abnormal)
			this.formRef.setValue(value)
		}catch(e){
			
		}
		
		this.rowsType = rowsType	// 分栏模式区分左右表格 2022/4/7  马婷
	}
	
	render(){
		return FormModal.call(this,{ title: '标本异常', labelWidth:'s3', width:500, api:'result-unit-item/update', getSubmit:param=>{
			const p = { spec_abnormal: window.$fn.getBody({ ...this.initSubmit.spec_abnormal, ...window.$fn.copy(param) }) }
			delete param.rongxue
			delete param.zhixue
			delete param.handan
			delete param.other
			return p
		},
			onRefresh:()=>{
				this.props.onRefresh({rowsType:this.rowsType})
			}
		})
	}
}

export default Index